1---
2// Content-collection-driven static page: prerendered at build time from the
3// `posts` collection (node prerendering); served from assets in production
4// and by Astro's node prerender middleware in dev.
5import { getCollection, render } from "astro:content";
6
7export const prerender = true;
8
9export async function getStaticPaths() {
10 const posts = await getCollection("posts");
11 return posts.map((post) => ({ params: { slug: post.id }, props: { post } }));
12}
13
14const { post } = Astro.props;
15const { Content } = await render(post);
16---
17
18<html lang="en">
19 <head>
20 <meta charset="utf-8" />
21 <meta name="viewport" content="width=device-width, initial-scale=1" />
22 <title>{post.data.title} — Astro Fixture</title>
23 </head>
24 <body>
25 <h1 id="post-title">{post.data.title}</h1>
26 <div id="post-body"><Content /></div>
27 <p><a href="/">home</a></p>
28 </body>
29</html>